<?php
class Application_Form_Password extends Zend_Form
{
	public function __construct($options = null)
	{
		$this->setName('password');
		$this->setMethod("post");
		
		$this->addElement("password", "oldpwd", array(
				'label'		 => 'Old Password:',
				'required'	 => true,
				'validators' => array(
						'NotEmpty'
				)
		));
		
		$this->addElement("password", "newpwd", array(
				'label'		 => 'New Password:',
				'required'	 => true,
				'validators' => array(
						'NotEmpty'
				)
		));
		$this->addElement("password", "renewpwd", array(
				'label'		 => 'Renew Password:',
				'required'	 => true,
				'validators' => array(
						'NotEmpty'
				)
		));
		
		
		// Un bouton d'envoi
		$this->addElement('submit', 'submit', array(
				'ignore'   => true,
				'label'    => 'Change',
				'test'	   => 'registration'
		));
		
		$this->setDecorators( array( array('ViewScript', array('viewScript' => 'forms/loginform.phtml'))));
	}
	
	public function isValid($data)
	{
		$password 	= $this->getElement('newpwd');
		$password->addValidator(new Zend_Validate_PasswordMatch($data['renewpwd']));
	
		return parent::isValid($data);
	}
}